package com.beyondsoft.sabg.edu.controller;

import com.beyondsoft.sabg.edu.model.dto.TeacherInfoDTO;
import com.beyondsoft.sabg.edu.model.vo.core.SimpleResponseVO;
import com.beyondsoft.sabg.edu.service.TeacherService;
import com.beyondsoft.sabg.edu.utils.PageUtils;
import com.beyondsoft.sabg.edu.utils.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 老师信息
 */
@RestController
@RequestMapping("/api/teacher")
public class TeacherInfoController {
    @Autowired
    private TeacherService teacherService;
    @PostMapping("/list/filter")
    @PreAuthorize("hasRole('TEACHER')||hasRole('ADMIN')")
    public SimpleResponseVO filterByPage(@RequestBody TeacherInfoDTO teacherInfoDTO) {
        Pageable pageable = PageUtils.initPage(teacherInfoDTO);
        return ResponseUtil.success().withData(teacherService.findAll(teacherInfoDTO, pageable));
    }

    @GetMapping("/college")
    public SimpleResponseVO getCollegeList(){
        return ResponseUtil.success().withData(teacherService.findCollegeList());
    }

    /**
     * 查询学院所有辅导员
     */
    @PostMapping("/findCollegeTeacher")
    public SimpleResponseVO getCollegeTeachers(){
        return ResponseUtil.success().withData(teacherService.findByCollegeIdAndPosition());
    }
}
